package com.wxxymakers.cklabrecruit.mapper;

import com.wxxymakers.cklabrecruit.entity.EmailTemplate;
import com.wxxymakers.cklabrecruit.entity.EmailTemplateExample;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface EmailTemplateMapper {

    @Select({
            "select Id, title, send_from, datetime ",
            "from email_template",
            "where title = #{title}"
    })
    @ResultMap("com.wxxymakers.cklabrecruit.mapper.EmailTemplateMapper.BaseResultMap")
    EmailTemplate selectByTitle(String title);

    long countByExample(EmailTemplateExample example);

    int deleteByExample(EmailTemplateExample example);

    @Delete({
        "delete from email_template",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into email_template (title, send_from, ",
        "datetime, content)",
        "values (#{title,jdbcType=VARCHAR}, #{sendFrom,jdbcType=VARCHAR}, ",
        "#{datetime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(EmailTemplate record);

    int insertSelective(EmailTemplate record);

    List<EmailTemplate> selectByExampleWithBLOBs(EmailTemplateExample example);

    List<EmailTemplate> selectByExample(EmailTemplateExample example);

    @Select({
        "select",
        "Id, title, send_from, datetime, content",
        "from email_template",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("com.wxxymakers.cklabrecruit.mapper.EmailTemplateMapper.ResultMapWithBLOBs")
    EmailTemplate selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") EmailTemplate record, @Param("example") EmailTemplateExample example);

    int updateByExampleWithBLOBs(@Param("record") EmailTemplate record, @Param("example") EmailTemplateExample example);

    int updateByExample(@Param("record") EmailTemplate record, @Param("example") EmailTemplateExample example);

    int updateByPrimaryKeySelective(EmailTemplate record);

    @Update({
        "update email_template",
        "set title = #{title,jdbcType=VARCHAR},",
          "send_from = #{sendFrom,jdbcType=VARCHAR},",
          "datetime = #{datetime,jdbcType=TIMESTAMP},",
          "content = #{content,jdbcType=LONGVARCHAR}",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(EmailTemplate record);

    @Update({
        "update email_template",
        "set title = #{title,jdbcType=VARCHAR},",
          "send_from = #{sendFrom,jdbcType=VARCHAR},",
          "datetime = #{datetime,jdbcType=TIMESTAMP}",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(EmailTemplate record);
}